package com.ls.controller.product;

import com.ls.controller.product.model.AddProductModel;
import com.ls.controller.product.model.EditProductModel;
import com.ls.controller.product.model.updateStatusModel;
import com.ls.service.IProductService;
import com.ls.utils.ResultData;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * <p>
 * 会员套餐 前端控制器
 * </p>
 *
 * @author pengyu
 * @since 2024-10-12
 */
@Api(value = "会员套餐相关接口", tags = "会员套餐相关接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/thali")
public class ProductController {
    private final IProductService service;
    /** 新增套餐 */
    @PostMapping("add")
    public ResultData add(@Valid @RequestBody AddProductModel model) {
        return service.add(model);
    }
    /** 编辑套餐 */
    @PostMapping("edit")
    public ResultData edit(@Valid @RequestBody EditProductModel model) {
        return service.edit(model);
    }
    /** 查询套餐列表 */
    @GetMapping("getProduct")
    public ResultData getProduct(Integer productType) {
        return service.getProduct(productType);
    }
    /** 删除套餐 */
    @PostMapping("del")
    public ResultData del(@RequestParam @NotNull(message = "id不得为空") Integer productId) {
        return service.del(productId);
    }
    /**修改套餐启用状态*/
    @PostMapping("updateStatus")
    public ResultData updateStatus(@Valid @RequestBody updateStatusModel model) {
        return service.updateStatus(model);
    }
}
